package com.sand.controller;

import com.sand.dto.supplier.DebtHuan;
import com.sand.dto.supplier.DebtSelecte;
import com.sand.entity.sell.Debt;
import com.sand.entity.sell.Logistics;
import com.sand.result.ResponseResult;
import com.sand.service.DebtService;
import com.sand.service.LogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/debt")
public class DebtController {

    @Autowired
    private DebtService debtService;


    /**
     * 添加货款债务
     */
    @PostMapping("/add")
    public ResponseResult<Integer> add(@RequestBody Debt debt){
        Integer i = debtService.add(debt);
        return new ResponseResult<Integer>().ok(i);
    }



    /**
     * 还财务
     */
    @PostMapping("/huan")
    public ResponseResult<Integer> huan(@RequestBody DebtHuan debtHuan){
        Integer i =  debtService.huan(debtHuan);
        return new ResponseResult<Integer>().ok(i);
    }

    /**
     * 条件查询货款债务
     */
    @PostMapping("/all")
    public ResponseResult<List<Debt>> all(@RequestBody DebtSelecte debtSelecte){
        List<Debt> list = debtService.all(debtSelecte);
        return new ResponseResult<List<Debt>>().ok(list);
    }

}
